﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Help;
using Model;
namespace BLLA
{
    public partial class Order_FlowMon_T : BaseBLL<Model.Order_FlowMon_T>, IBLL.IOrder_FlowMon_TBLL
    {
        ObjectSerialize os = new ObjectSerialize();
        DataResult result = new DataResult();

        /// <summary>
        /// 查询金额流水
        /// </summary>
        /// <param name="YZM">验证码</param>
        /// <param name="RETID">数据格式（1：JSON；2：XML）</param>
        /// <returns></returns>
        public string GetOrder_FlowMon(int pageIndex, int pageSize, string AccNum, string WaltID, string WaltFlowType, string StarTime, string EndTime, string YZM, int RETID)
        {
            #region 匹配验证码
            if (YZM != Help.ALL_DataV.YZM)
            {
                result.BS = "-88";
                result.Msg = "验证码错误！";
                return os.StringOfObject(result, RETID);
            }
            #endregion
            #region 业务层
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("SELECT  * FROM View_FlowMon where 1=1");
                if (AccNum != "")
                {
                    sql.Append(" and AccNum like '%" + AccNum + "%' ");
                }
                if (WaltID.Trim() != "")
                {
                    sql.Append(" and WaltID = '" + WaltID + "'");
                }
                if (WaltFlowType != "")
                {
                    sql.Append(" and WaltFlowType = '" + WaltFlowType + "' ");
                }
                if (StarTime != "")
                {
                    sql.Append(" and WaltFlowTime >= '" + StarTime + "' ");
                }
                if (EndTime != "")
                {
                    sql.Append(" and WaltFlowTime <= '" + EndTime + "' ");
                }
                sql.Append(" order by WaltFlowTime desc");
                List<Model.View_FlowMon> ls = base.DBSession.IView_FlowMonDAL.GetListBy(sql.ToString());
                if (ls != null && ls.Count > 0)
                {
                    result.BS = "1";
                    result.Msg = "查询成功！";
                    result.total = ls.Count;
                    result.rows = ls.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                }
                else
                {
                    result.BS = "0";
                    result.Msg = "查询不到数据";
                }
                return os.StringOfObject(result, RETID);
            }
            catch (Exception ex)
            {
                WriteLog.WriteW("查询金额流水失败：" + ex.Message);
                result.BS = "-99";
                result.Msg = "系统错误！";
                return os.StringOfObject(result, RETID);
            }

            #endregion
        }


        public string GetOrder_FlowMonByAccIDAndWaltID(int pageIndex, int pageSize, string AccID, string WaltID, string YZM, int RETID)
        {
            #region 匹配验证码
            if (YZM != Help.ALL_DataV.YZM)
            {
                result.BS = "-88";
                result.Msg = "验证码错误！";
                return os.StringOfObject(result, RETID);
            }
            #endregion
            #region 业务层
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("SELECT  * FROM View_FlowMon where 1=1");
                if (AccID != "")
                {
                    sql.Append(" and  AccID = " + AccID + " ");
                }
                if (WaltID.Trim() != "")
                {
                    sql.Append(" and WaltID = '" + WaltID + "'");
                }
                List<Model.View_FlowMon> ls = base.DBSession.IView_FlowMonDAL.GetListBy(sql.ToString());
                if (ls != null && ls.Count > 0)
                {
                    result.BS = "1";
                    result.Msg = "查询成功！";
                    result.total = ls.Count;
                    result.rows = ls.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                }
                else
                {
                    result.BS = "0";
                    result.Msg = "查询不到数据";
                }
                return os.StringOfObject(result, RETID);
            }
            catch (Exception ex)
            {
                WriteLog.WriteW("查询金额流水失败：" + ex.Message);
                result.BS = "-99";
                result.Msg = "系统错误！";
                return os.StringOfObject(result, RETID);
            }

            #endregion
        }
    }
}
